package com.jason.order.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface IOrderTCCService {
    /**
     * useTCCFence：1.5。1新加字段，之前需要手动编程来进行  幂等、悬挂和空回滚  问题的处理，加了这个字段后可将这个功能交给tcc_fence_log表来处理
     * 开启useTCCFence时，seata会使用tcc_fence_log表，与业务事务同时提交，RM会根据这个表是否有数据、status状态判断prepare
     * 动作是否完成来决定是否执行commmit或rollback
     */
    @TwoPhaseBusinessAction(name = "order", commitMethod = "commit", rollbackMethod = "rollback",useTCCFence = true)
    boolean prepare(BusinessActionContext businessActionContext,@BusinessActionContextParameter(paramName = "id") Integer id,
                    @BusinessActionContextParameter(paramName = "status") Integer status);

    boolean commit(BusinessActionContext businessActionContext);

    boolean rollback(BusinessActionContext businessActionContext);
}
